import { IPSAppCodeList } from '../codelist/ipsapp-code-list';
import { IPSAppDEAction } from './ipsapp-deaction';
import { IPSAppDEDataSet } from './ipsapp-dedata-set';
import { IPSAppDELogic } from './ipsapp-delogic';
import { IPSAppDEMethod } from './ipsapp-demethod';
import { IPSAppDEMethodInput } from './ipsapp-demethod-input';
import { IPSAppDEMethodReturn } from './ipsapp-demethod-return';
import { IPSAppDataEntity } from './ipsapp-data-entity';
import { IPSDEAction } from '../../dataentity/action/ipsdeaction';
import { IPSDEDQCondition } from '../../dataentity/ds/ipsdedqcondition';
import { IPSDEDQGroupCondition } from '../../dataentity/ds/ipsdedqgroup-condition';
import { IPSDEDataSet } from '../../dataentity/ds/ipsdedata-set';
import { IPSDEOPPriv } from '../../dataentity/priv/ipsdeoppriv';
import { IPSDEServiceAPIMethod } from '../../dataentity/service/ipsdeservice-apimethod';
import { IPSSysPFPlugin } from '../../res/ipssys-pfplugin';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSAppDEMethodImpl extends PSModelObjectImpl implements IPSAppDEMethod, IPSAppDEAction, IPSAppDEDataSet {
  protected adpsdedqconditions: IPSDEDQCondition[] | null = null;

  getADPSDEDQConditions(): IPSDEDQCondition[] | null {
    if (this.adpsdedqconditions == null) {
      this.adpsdedqconditions = this.fillChildListModel(this.M.getADPSDEDQConditions, 'dataentity.ds.IPSDEDQCondition') as IPSDEDQCondition[];
    }
    return this.adpsdedqconditions;
  }

  get aDPSDEDQConditions(): IPSDEDQCondition[] | null {
    return this.getADPSDEDQConditions();
  }

  findADPSDEDQCondition(objKey: any): IPSDEDQCondition | null {
    return this.getPSModel5('dataentity.ds.IPSDEDQCondition', this.getADPSDEDQConditions(), objKey) as IPSDEDQCondition;
  }

  get actionMode(): 'CREATE' | 'READ' | 'UPDATE' | 'DELETE' | 'CUSTOM' | 'GETDRAFT' | 'UNKNOWN' | 'MOVEORDER' | 'CHECKKEY' | 'USER' | 'USER2' | 'USER3' | 'USER4' {
    return this.M.actionMode;
  }

  get actionType(): 'USERCUSTOM' | 'DELOGIC' | 'BUILTIN' | 'SELECTBYKEY' | 'USERCREATE' | 'USERUPDATE' | 'USERSYSUPDATE' | 'SCRIPT' | 'REMOTE' {
    return this.M.actionType || 'REMOTE';
  }

  get afterCode(): string {
    return this.M.afterCode;
  }

  get batchActionMode(): 0 | 1 | 2 | 5 | 6 {
    return this.M.batchActionMode != null ? this.M.batchActionMode : 0;
  }

  get beforeCode(): string {
    return this.M.beforeCode;
  }

  get codeName(): string {
    return this.M.codeName;
  }

  get codeName2(): string {
    return this.M.codeName2;
  }

  get dataSetType(): 'DATAQUERY' | 'INDEXDE' | 'MULTIFORM' | 'CODELIST' | 'DELOGIC' | 'SCRIPT' | 'REMOTE' {
    return this.M.dataSetType || 'REMOTE';
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get memo(): string {
    return this.M.memo;
  }

  get methodType(): 'DEACTION' | 'FETCH' | 'SELECT' | 'FETCHTEMP' | 'SELECTTEMP' | 'WFACTION' | 'FILTERACTION' | 'USER' | 'USER2' | 'USER3' | 'USER4' {
    return this.M.methodType;
  }

  get name(): string {
    return this.M.name;
  }

  protected psappcodelist: IPSAppCodeList | null = null;

  getPSAppCodeList(): IPSAppCodeList | null {
    if (this.psappcodelist != null) return this.psappcodelist;
    const value = this.M.getPSAppCodeList;
    if (value == null) {
      return null;
    }
    this.psappcodelist = this.getPSModel4('app.codelist.IPSAppCodeList', value, 'getPSAppCodeList') as IPSAppCodeList;
    return this.psappcodelist;
  }

  get psAppCodeList(): IPSAppCodeList | null {
    return this.getPSAppCodeList();
  }

  getPSAppCodeListMust(): IPSAppCodeList {
    const value = this.getPSAppCodeList();
    if (value == null) {
      throw new Error('未指定应用代码表');
    }
    return value;
  }

  protected psappdelogic: IPSAppDELogic | null = null;

  getPSAppDELogic(): IPSAppDELogic | null {
    if (this.psappdelogic != null) return this.psappdelogic;
    const value = this.M.getPSAppDELogic;
    if (value == null) {
      return null;
    }
    const ipsappdataentity = this.getParentPSModelObject('app.dataentity.IPSAppDataEntity') as IPSAppDataEntity;
    if (ipsappdataentity != null) {
      this.psappdelogic = ipsappdataentity.findPSAppDELogic(value);
    }
    return this.psappdelogic;
  }

  get psAppDELogic(): IPSAppDELogic | null {
    return this.getPSAppDELogic();
  }

  getPSAppDELogicMust(): IPSAppDELogic {
    const value = this.getPSAppDELogic();
    if (value == null) {
      throw new Error('未指定实体处理逻辑');
    }
    return value;
  }

  protected psappdemethodinput: IPSAppDEMethodInput | null = null;

  getPSAppDEMethodInput(): IPSAppDEMethodInput | null {
    if (this.psappdemethodinput != null) return this.psappdemethodinput;
    const value = this.M.getPSAppDEMethodInput;
    if (value == null) {
      return null;
    }
    this.psappdemethodinput = this.getPSModel4('app.dataentity.IPSAppDEMethodInput', value, 'getPSAppDEMethodInput') as IPSAppDEMethodInput;
    return this.psappdemethodinput;
  }

  get psAppDEMethodInput(): IPSAppDEMethodInput | null {
    return this.getPSAppDEMethodInput();
  }

  getPSAppDEMethodInputMust(): IPSAppDEMethodInput {
    const value = this.getPSAppDEMethodInput();
    if (value == null) {
      throw new Error('未指定方法输入对象');
    }
    return value;
  }

  protected psappdemethodreturn: IPSAppDEMethodReturn | null = null;

  getPSAppDEMethodReturn(): IPSAppDEMethodReturn | null {
    if (this.psappdemethodreturn != null) return this.psappdemethodreturn;
    const value = this.M.getPSAppDEMethodReturn;
    if (value == null) {
      return null;
    }
    this.psappdemethodreturn = this.getPSModel4('app.dataentity.IPSAppDEMethodReturn', value, 'getPSAppDEMethodReturn') as IPSAppDEMethodReturn;
    return this.psappdemethodreturn;
  }

  get psAppDEMethodReturn(): IPSAppDEMethodReturn | null {
    return this.getPSAppDEMethodReturn();
  }

  getPSAppDEMethodReturnMust(): IPSAppDEMethodReturn {
    const value = this.getPSAppDEMethodReturn();
    if (value == null) {
      throw new Error('未指定方法返回对象');
    }
    return value;
  }

  protected psdeaction: IPSDEAction | null = null;

  getPSDEAction(): IPSDEAction | null {
    if (this.psdeaction != null) return this.psdeaction;
    const value = this.M.getPSDEAction;
    if (value == null) {
      return null;
    }
    const ipsappdataentity = this.getParentPSModelObject('app.dataentity.IPSAppDataEntity') as IPSAppDataEntity;
    if (ipsappdataentity != null) {
      this.psdeaction = ipsappdataentity.getPSDataEntityMust().findPSDEAction(value);
    }
    return this.psdeaction;
  }

  get psDEAction(): IPSDEAction | null {
    return this.getPSDEAction();
  }

  getPSDEActionMust(): IPSDEAction {
    const value = this.getPSDEAction();
    if (value == null) {
      throw new Error('未指定实体行为');
    }
    return value;
  }

  protected psdedqgroupconditions: IPSDEDQGroupCondition[] | null = null;

  getPSDEDQGroupConditions(): IPSDEDQGroupCondition[] | null {
    if (this.psdedqgroupconditions == null) {
      this.psdedqgroupconditions = this.fillChildListModel(this.M.getPSDEDQGroupConditions, 'dataentity.ds.IPSDEDQGroupCondition') as IPSDEDQGroupCondition[];
    }
    return this.psdedqgroupconditions;
  }

  get psDEDQGroupConditions(): IPSDEDQGroupCondition[] | null {
    return this.getPSDEDQGroupConditions();
  }

  findPSDEDQGroupCondition(objKey: any): IPSDEDQGroupCondition | null {
    return this.getPSModel5('dataentity.ds.IPSDEDQGroupCondition', this.getPSDEDQGroupConditions(), objKey) as IPSDEDQGroupCondition;
  }

  protected psdedataset: IPSDEDataSet | null = null;

  getPSDEDataSet(): IPSDEDataSet | null {
    if (this.psdedataset != null) return this.psdedataset;
    const value = this.M.getPSDEDataSet;
    if (value == null) {
      return null;
    }
    const ipsappdataentity = this.getParentPSModelObject('app.dataentity.IPSAppDataEntity') as IPSAppDataEntity;
    if (ipsappdataentity != null) {
      this.psdedataset = ipsappdataentity.getPSDataEntityMust().findPSDEDataSet(value);
    }
    return this.psdedataset;
  }

  get psDEDataSet(): IPSDEDataSet | null {
    return this.getPSDEDataSet();
  }

  getPSDEDataSetMust(): IPSDEDataSet {
    const value = this.getPSDEDataSet();
    if (value == null) {
      throw new Error('未指定实体数据集合');
    }
    return value;
  }

  protected psdeoppriv: IPSDEOPPriv | null = null;

  getPSDEOPPriv(): IPSDEOPPriv | null {
    if (this.psdeoppriv != null) return this.psdeoppriv;
    const value = this.M.getPSDEOPPriv;
    if (value == null) {
      return null;
    }
    this.psdeoppriv = this.getPSModel4('dataentity.priv.IPSDEOPPriv', value, 'getPSDEOPPriv') as IPSDEOPPriv;
    return this.psdeoppriv;
  }

  get psDEOPPriv(): IPSDEOPPriv | null {
    return this.getPSDEOPPriv();
  }

  getPSDEOPPrivMust(): IPSDEOPPriv {
    const value = this.getPSDEOPPriv();
    if (value == null) {
      throw new Error('未指定默认操作标识');
    }
    return value;
  }

  protected psdeserviceapimethod: IPSDEServiceAPIMethod | null = null;

  getPSDEServiceAPIMethod(): IPSDEServiceAPIMethod | null {
    if (this.psdeserviceapimethod != null) return this.psdeserviceapimethod;
    const value = this.M.getPSDEServiceAPIMethod;
    if (value == null) {
      return null;
    }
    const ipsappdataentity = this.getParentPSModelObject('app.dataentity.IPSAppDataEntity') as IPSAppDataEntity;
    if (ipsappdataentity != null) {
      this.psdeserviceapimethod = ipsappdataentity.getPSDEServiceAPIMust().findPSDEServiceAPIMethod(value);
    }
    return this.psdeserviceapimethod;
  }

  get psDEServiceAPIMethod(): IPSDEServiceAPIMethod | null {
    return this.getPSDEServiceAPIMethod();
  }

  getPSDEServiceAPIMethodMust(): IPSDEServiceAPIMethod {
    const value = this.getPSDEServiceAPIMethod();
    if (value == null) {
      throw new Error('未指定服务接口方法');
    }
    return value;
  }

  protected pssyspfplugin: IPSSysPFPlugin | null = null;

  getPSSysPFPlugin(): IPSSysPFPlugin | null {
    if (this.pssyspfplugin != null) return this.pssyspfplugin;
    const value = this.M.getPSSysPFPlugin;
    if (value == null) {
      return null;
    }
    this.pssyspfplugin = this.getPSModel4('res.IPSSysPFPlugin', value, 'getPSSysPFPlugin') as IPSSysPFPlugin;
    return this.pssyspfplugin;
  }

  get psSysPFPlugin(): IPSSysPFPlugin | null {
    return this.getPSSysPFPlugin();
  }

  getPSSysPFPluginMust(): IPSSysPFPlugin {
    const value = this.getPSSysPFPlugin();
    if (value == null) {
      throw new Error('未指定前端扩展插件');
    }
    return value;
  }

  get predefinedType(): 'CODELIST' | 'INDEXDE' | 'MULTIFORM' | 'DELOGIC' | 'SCRIPT' | 'REMOTE' {
    return this.M.predefinedType;
  }

  get requestField(): string {
    return this.M.requestField;
  }

  protected requestfullpaths: string[] | null = null;

  getRequestFullPaths(): string[] | null {
    if (this.requestfullpaths == null) {
      const value = this.M.requestFullPaths;
      if (value == null) {
        return null;
      }
      const arrayNode: any[] = value;
      if (arrayNode.length == 0) {
        return null;
      }
      const list: string[] = [];
      for (let i = 0; i < arrayNode.length; i++) {
        list.push(arrayNode[i]);
      }
      this.requestfullpaths = list;
    }
    return this.requestfullpaths;
  }

  get requestFullPaths(): string[] | null {
    return this.getRequestFullPaths();
  }

  get requestMethod(): 'GET' | 'HEAD' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'TRACE' {
    return this.M.requestMethod;
  }

  get requestParamType(): 'NONE' | 'FIELD' | 'FIELDS' | 'ENTITY' | 'ENTITIES' | 'OBJECT' | 'OBJECTS' {
    return this.M.requestParamType;
  }

  get requestPath(): string {
    return this.M.requestPath;
  }

  get scriptCode(): string {
    return this.M.scriptCode;
  }

  get tempDataMode(): 0 | 1 | 2 {
    return this.M.tempDataMode != null ? this.M.tempDataMode : 0;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get asyncAction(): boolean {
    return this.M.asyncAction != null ? this.M.asyncAction : false;
  }

  get builtinMethod(): boolean {
    return this.M.builtinMethod;
  }

  get customCode(): boolean {
    return this.M.customCode != null ? this.M.customCode : false;
  }

  get enableBatchAction(): boolean {
    return this.M.enableBatchAction != null ? this.M.enableBatchAction : false;
  }

  get enableTestMethod(): boolean {
    return this.M.enableTestMethod != null ? this.M.enableTestMethod : false;
  }

  get needResourceKey(): boolean {
    return this.M.needResourceKey != null ? this.M.needResourceKey : false;
  }

  get noServiceCodeName(): boolean {
    return this.M.noServiceCodeName != null ? this.M.noServiceCodeName : false;
  }

  get cls(): string {
    return 'PSAppDEMethodImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'app.dataentity.IPSAppDEAction' || cls == 'app.dataentity.IPSAppDEDataSet' || cls == 'app.dataentity.IPSAppDEMethod' || cls == 'app.dataentity.IPSAppDataEntityObject') return true;
    return super.instanceof(cls);
  }
}
